package com.maxatime.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.maxatime.common.constant.BusinessContents;
import com.maxatime.pojo.entity.ExamStorage3;
import com.maxatime.service.Ssbkaoshi6;

//四月份考试
@Controller
@RequestMapping("/Ssbcontroller6")
public class Ssbcontroller6 {
	@Autowired
	Ssbkaoshi6 Ssbkaoshi6;
	
	//查询
	@RequestMapping("/quest")
	@ResponseBody
	public Map<String, Object> quest(@RequestBody ExamStorage3 examStorage3) {
		Map<String, Object> m = new HashMap<>();
		Map<String, Object> list = Ssbkaoshi6.list(examStorage3);
		m.put(BusinessContents.CODE, "0000");
		m.put(BusinessContents.MSG, "交易成功");
		m.put(BusinessContents.DATA, list.get("list"));
		m.put("pageInfo", list.get("pageInfo"));
		return m;
	}
	
	//新增
	@RequestMapping("/save")
	@ResponseBody
	public Map<String, Object> save(@RequestBody ExamStorage3 examStorage3) {
		Map<String, Object> m = new HashMap<>();
		Ssbkaoshi6.insertSelective(examStorage3);
		m.put(BusinessContents.CODE, "1111");
		m.put(BusinessContents.MSG, "新增成功");
		return m;
	}
	
	//删除
	@RequestMapping("/del")
	@ResponseBody
	public Map<String, Object> del(@RequestBody String jsonStr) {
		
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		int pkId = jsonObj.getInteger("pkId");
		Map<String, Object> m = new HashMap<>();
		Ssbkaoshi6.deleteByPrimaryKey(pkId);
		m.put(BusinessContents.CODE, "2222");
		m.put(BusinessContents.MSG, "删除成功");
		return m;
	}
	//反显
	@RequestMapping("/find")
	@ResponseBody
	public Map<String, Object> find(@RequestBody String jsonStr) {
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		Map<String, Object> m = new HashMap<>();
		int pkId = jsonObj.getInteger("pkId");
		ExamStorage3 find = Ssbkaoshi6.find(pkId);
		m.put(BusinessContents.CODE, "3333");
		m.put(BusinessContents.MSG, "反显成功");
		m.put(BusinessContents.DATA, find);
		return m;
	}
	// 修改
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> update(@RequestBody ExamStorage3 examStorage3) {
		Map<String, Object> m = new HashMap<>();
		Ssbkaoshi6.updateByPrimaryKeySelective(examStorage3);
		m.put(BusinessContents.CODE, "4444");
		m.put(BusinessContents.MSG, "修改成功");
		return m;
	}
}
